/*              Copyright(c) 2008 Dave Sexton              *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;

namespace DaveSexton.Sandcastle
{
	public sealed class DatabaseUrlMappingProviderSettings
	{
		#region Public Properties
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1802:UseLiteralsWhereAppropriate")]
		public static readonly string DefaultIdColumnName = "ID", DefaultHrefColumnName = "HREF", DefaultDataProvider = "System.Data.OleDb";

		public string Connection
		{
			get
			{
				return connection;
			}
			set
			{
				connection = (value == null) ? null : value.Trim();
			}
		}

		public string Provider
		{
			get
			{
				if (string.IsNullOrEmpty(provider))
					return DefaultDataProvider;
				else
					return provider;
			}
			set
			{
				provider = (value == null) ? null : value.Trim();
			}
		}

		public string Query
		{
			get
			{
				return query;
			}
			set
			{
				query = (value == null) ? null : value.Trim();
			}
		}

		public string IdColumn
		{
			get
			{
				if (string.IsNullOrEmpty(idColumn))
					return DefaultIdColumnName;
				else
					return idColumn;
			}
			set
			{
				idColumn = (value == null) ? null : value.Trim();
			}
		}

		public string HrefColumn
		{
			get
			{
				if (string.IsNullOrEmpty(hrefColumn))
					return DefaultHrefColumnName;
				else
					return hrefColumn;
			}
			set
			{
				hrefColumn = (value == null) ? null : value.Trim();
			}
		}

		public bool StoredProcedure
		{
			get
			{
				return storedProcedure;
			}
			set
			{
				storedProcedure = value;
			}
		}

		public int? CommandTimeout
		{
			get
			{
				return commandTimeout;
			}
			set
			{
				commandTimeout = value;
			}
		}

		public IEnumerable<QueryParameter> Parameters
		{
			get
			{
				return parameters;
			}
			set
			{
				parameters = value;
			}
		}
		#endregion

		#region Private / Protected
		private string connection, provider, query, idColumn, hrefColumn;
		private bool storedProcedure;
		private int? commandTimeout;
		IEnumerable<QueryParameter> parameters;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="DatabaseUrlMappingProviderSettings" /> class.
		/// </summary>
		public DatabaseUrlMappingProviderSettings()
		{
		}
		#endregion
	}
}
